package com.zmn.brs.common.enums;

import com.zmn.common.constant.GlobalConsts;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 类描述：平台枚举
 *
 * @author zhangyao
 * @since 2021/04/20 11:32
 */
public enum PlatEnum {

    ZMN_PLAT(GlobalConsts.PLAT_MARK_ZMN, "啄木鸟平台"),
    YEYX_PLAT(GlobalConsts.PLAT_MARK_YEYX, "言而有信平台"),
    SAAS_PLAT(GlobalConsts.PLAT_MARK_SAAS, "一步维修平台"),
    CNHB_PLAT(GlobalConsts.PLAT_MARK_CNHB, "川南环保平台");

    /**
     * 编码
     */
    private final Integer code;

    /**
     * 名称
     */
    private final String name;


    PlatEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static PlatEnum getPlatEnum(Integer code) {
        Optional<PlatEnum> optional = Stream.of(PlatEnum.values()).filter(e -> e.getCode().equals(code)).findFirst();
        return optional.orElse(null);
    }

    @Override
    public String toString() {
        return "PlatEnum{" +
                "code=" + code +
                ", name='" + name + '\'' +
                '}';
    }
}
